package es.xpt.ysf.commons.track;

import es.xpt.ysf.YSFException;
import es.xpt.ysf.commons.Names;
import es.xpt.ysf.logging.LogManager;
import es.xpt.ysf.track.Track;
import es.xpt.ysf.track.TrackUtils;
import es.xpt.ysf.utils.ServiceLocator;

public class TrackMessageUtils {
		
	public static void queueTrack(Track track) {
		try {
			if (track.getPrincipal() == null)
				track.setPrincipal(TrackUtils.getTrackPrincipal());
			
			ServiceLocator sl = new ServiceLocator(track.getPrincipal(), "");
			TrackSession ts = (TrackSession)sl.getLocal(Names.TRACK);
			ts.insertTrack(track);
		} catch (YSFException e) {
			LogManager.getLog(TrackMessageUtils.class).error("Error al conseguir referencia a la cola de track", e);
		}
	}

}
